package p1290

import node.ListNode

class RecursionStragty : Stragty {
    //递归，参考leetcode题库中逆序打印链表的思路
    var sum: Int = 0
    var level: Int = 0

    override fun getDecimalValue(head: ListNode?): Int {
        if (head == null)
            return 0;
        sum += getDecimalValue(head.next) + (Math.pow(2.0, level * 1.0) * head.`val`).toInt()
        level++
        return sum
    }
}